import * as React from "react";
import { View, Text, StyleSheet } from "react-native";

export default class NativePropsButton extends React.PureComponent {
  _refButton: any;

  render() {
    return (
      <View
        style={styles.buttonStyle}
        ref={(ref: any) => (this._refButton = ref)}
        onTouchStart={() => this._onTouchStart()}
        onTouchEnd={() => this._onTouchEnd()}
      >
        <Text style={styles.textStyle}>{this.props.children}</Text>
      </View>
    );
  }

  _onTouchStart = () => {
    this._refButton.setNativeProps({
      style: { backgroundColor: "#666" }
    });
  };

  _onTouchEnd = () => {
    this._refButton.setNativeProps({
      style: { backgroundColor: "#999" }
    });
  };
}

const styles = StyleSheet.create({
  buttonStyle: {},
  textStyle: {}
});
